// cats.controller.ts
import {
  Controller,
  Get,
  Post,
  Body,
  Req,
  Request,
  Delete,
  Patch,
  Inject,
  UseGuards
} from '@nestjs/common';
import { EssayService } from '../service/essay.service';
import { ClientProxy } from '@nestjs/microservices';
import { AuthGuard } from '@nestjs/passport';

@Controller('essay')
export class EssayController {
  constructor(
    private readonly essayService: EssayService,
    @Inject('basic-service') private basicClient: ClientProxy,
  ) {}

  @Get('get-all')
  @UseGuards(AuthGuard('jwt')) //jwt策略，身份鉴权
  async get(@Req() request: any): Promise<any> {
    return 'essay list Get';
  }

  @Get('basic')
  async getByBasic(@Req() request: any): Promise<any> {
    return this.basicClient.send('basic', 'grpc');
  }

  @Post('add')
  async add(@Body() body: any, @Req() request: any): Promise<any> {
    return 'essay list Post';
  }

  @Post('update')
  async update(@Body() body: any, @Req() request: any): Promise<any> {
    return 'essay list Patch';
  }

  @Post('remove')
  async remove(@Body() body: any, @Req() request: any): Promise<any> {
    return 'essay list Delete';
  }
}
